$(function(){


	/** 首页 导航栏鼠标移入移出事件 */
   $(".layui-tab .layui-tab-title li").on({
      mouseover : function(){
      	
      	$(this).addClass("active");
        $(this).css("background","rgba(0,201,87,0.5)");
        var pos = findPosition($(this).children("span").text());
        $(".layui-tab .layui-tab-content .layui-tab-item").eq(pos).css("display","inline-block");
      } ,
      mouseout : function(){

      	var pos = findPosition($(this).children("span").text());
      	console.log("===========pos:"+pos);
        $(".layui-tab .layui-tab-content .layui-tab-item").eq(pos).css("display","none");

        $(this).css("background","unset");
      	$(this).removeClass("active");
      } 

      });


     
      var productJSON =  [{"img":"image/product/fruit.png"},
					      {"img":"image/product/seafood.png"},
					      {"img":"image/product/vegetables.png"},
					      {"img":"image/product/milk.png"},
					      {"img":"image/product/liqueur.png"},
					      {"img":"image/product/egg.png"},
					      {"img":"image/product/Snacks.png"},
					      {"img":"image/product/meat.png"}];

        /** 遍历今日特卖 */
       loadTodayProduct(productJSON);

   


	    /** 遍历今日特卖 */
	   function loadTodayProduct(productJSON){

	        var ITEMS = "";
		   	for(var index in productJSON){
	             ITEMS +='<li><img src="'+productJSON[index].img+'"></li>';
		   	}
		   	$(".ul-today").html(ITEMS);
	   }


	    function findPosition(text){

	       var spanElems = $(".layui-tab .layui-tab-title li span");

	       for(var i = 0; i < spanElems.length; i++){
	           if(spanElems.eq(i).text() == text){
	               return i;
	           }
	       }
	    }

});